Skip to main content

Mapping a Hardware Structure in the Device Tree

You map the hardware that you control with your application in the Devices view (device tree). To do this, insert device objects into this tree structure which represent physical devices in the network until the hierarchy reflects the controller network. Device objects are, for example, a PLC object, a fieldbus object, or a logical device.

Mapping a standard controller with fieldbus in the device tree

Below you will map hardware containing a standard PLC and a standard fieldbus.

  1. Click File → New Project.

  2. In the New Project dialog, select the Standard Project template.

  3. In the Standard Project dialog, select the CODESYS Control Win device.

    _cds_img_standard_device_tree.png

    CODESYS inserts the Device (CODESYS Control Win) object in the device tree below the root node and below it the PLC Logic node, which always provides a programmable device object. An Application object exists below that, and the Library Manager, PLC_PRG, and Task Configuration objects exist below that.

  4. Select the Device entry and click Add Device in the context menu.

    The Add Device dialog provides a selection of the devices installed on your system. "Installed on the system" means that CODESYS has received a device description for the respective hardware. As a result, you can use the device object and the associated configuration editor in the project.

  5. Select one of the provided PLCs (example: CAN-bus) and click the Add Device button.

    The CAN-Bus object is displayed in the device tree indented below Device (CODESYS). The Add Device dialog remains open. Now when you select the new CAN-bus entry, it automatically offers the objects that are insertable under it.

  6. For example, select the CANopen Device from the Local Device category.

    CANopen_Device is inserted indented under CAN-bus in the device tree.

  7. Do you want to add a different device to the one you added before? Select the device entry and click Update Device in the context menu.

    The Update Device dialog opens. It corresponds to the Add Device dialog used previously. You can select another device, which is then inserted in the tree in place of the previous one.

Scanning the current hardware and applying devices into the project

You can determine the devices in the network of the hardware environment (scan) and apply the devices found into the device tree of your project.

If the scan function is permanently implemented in the PLC, you can perform the scan without further preparations. For this purpose, CODESYS establishes a temporary connection to the controller. If the scan function is provided in a library, then the device which includes the library has to be inserted in the device tree and a login to the controller executed. Only after that can the library be placed on the controller, making scanning possible.

Scanning is started by means of the Scan for Devices command. It refers to the controller which is currently selected in the device tree and linked to the project. For example, you can select an inserted PROFINET IO Controller and use the command to determine the I/O Devices and I/O Modules assigned to it.

Requirement: Your project has a device configuration. The communication settings are correct. Gateways and hardware are running.

  1. Select a controller object in the device tree.

  2. In the context menu, click Scan for Devices.

    CODESYS establishes the connection to the hardware. The Scan for Devices dialog opens. Depending on the type of device, it offers different functions. However, a table always appears, showing the devices found in the hardware: device name, type of device, station name, etc. For more information about this, see the help for the respective device editor.

  3. So that the list displays only devices found which you do not yet have in the device configuration of your project, select the Show differences to project option.

  4. In order to apply a device into the device tree of the project, select the entry in the table and click the Copy to Project button. All devices found are applied if you do not select an entry.

    The corresponding entries are inserted in the device tree.

Checking the controller configuration with the help of the Online Config Mode command

With CODESYS you can test the correct wiring of the I/Os and the fieldbus of your target system, without having to develop a real application for the controller and loading it to the controller beforehand. This is interesting for the initial commissioning phase. Use the "Simple online configuration mode" for this. If an application already exists on the controller, then as an option you could also use the "Advanced online configuration mode" if the device supports this. This allows you to read device parameters without having to log in with the affected application from CODESYS.

Simple online configuration mode

You can use the Online Config Mode command in the context menu of the PLC object in the device tree in order to create an implicit application. CODESYS automatically downloads the application to the PLC and automatically initializes all I/Os one time by means of the application. The application is named HiddenOnlineConfigModeApp. It is displayed in the device editor of the PLC on the Applications tab. You can use it to operate the I/Os with the following functions as in normal online mode:

  • Read I/Os

  • Write outputs

  • Diagnosis (in the tree and on the status page)

  • Scan (of the current hardware)

  • Interactive online functions, if supported (for example, writing asynchronous messages)

Writing and forcing in the I/O mapping

In online configuration mode, the writing and forcing of values in the I/O Mapping dialog works differently to the way it works in real online mode. CODESYS writes the outputs into the I/O mapping table immediately after being inserted. There is no Prepared Value column. Instead, you change the initial values directly after you double-click the Current Value column.

Testing the I/O access with the help of the simple online configuration mode

Requirement: You have created a standard project with a device configuration in which you have configured an I/O mapping. In a program POU, you make read or write accesses to inputs or outputs of the hardware in order to check their wiring. The connection to the PLC of the hardware is configured in the communication settings. The PLC is running.

  1. Select the PLC object in the device tree.

    For example, the _cds_icon_device.png CODESYS Control Win device is selected in the device tree.

  2. In the context menu, click Online Config Mode.

    CODESYS connects to the controller and the PLC object in the tree is given a green background.

  3. In the device tree, double-click the PLC object to open the device editor. Select the Applications tab.

  4. Click the Refresh list button.

    The HiddenOnlineConfigModeApp application is displayed in the Applications on the PLC window.

  5. Start your program and check the behavior of the inputs and outputs.

Advanced online configuration mode (parameter mode)

If a real application already exists on the controller and the device supports the "Advanced online configuration mode", then as an option you could also select the "Parameter Mode" after the Online Configuration Mode command. Then you can read the parameters of the real application on the controller without having to perform a standard login and – if compile information is missing – having to download this application again. You can see the parameters on the Configuration tab of the device editor. The parameter mode prevents from accidentally changing the data on the controller; the applications remain untouched. Writing of the parameters is possible only if the driver supports it.

Setting up parameter mode for reading the device parameters

Requirement: There is already one or more applications on the target device. The target device supports the advanced online configuration mode. You have opened the project containing these applications. You want to look at the device parameters without having to log in to the controller. The connection to the PLC of the hardware is configured in the communication settings. The PLC is running.

  1. Select the PLC object in the device tree.

  2. In the context menu, click Online Config Mode.

    CODESYS connects to the controller and the PLC object in the tree is given a green background. The Select Configuration Mode dialog opens with a display of the application(s) on the PLC.

  3. Select the desired application and click the Parameter Mode button.

    CODESYS checks whether or not the application in the project corresponds to the application on the PLC.

  4. If CODESYS does not report an error that the applications do not match, then open the Configuration tab of the PLC device editor.

    You can read the device parameters.